<template>
  <div ref="scrolls">
    <div>
      <slot></slot>
    </div>
  </div>
</template>

<script>
import Scroll from "better-scroll";
export default {
  data() {
    return {
      scroll: null,
    };
  },
  // emits:["pullingUp"],
  props: {
    probeTypes: {
      type: Number,
      default: 0,
    },
    pullUpload: {
      type: Boolean,
      default: false,
    },
  },
  methods: {},
  mounted() {
    this.scroll = new Scroll(this.$refs.scrolls, {
      click: true,
      observeDOM: true,
      probeType: this.probeTypes,
      pullUpLoad: this.pullUpload,
    });
    this.scroll.on("scroll", (position) => {
      position = Math.floor(parseInt(position.y));
      this.$store.commit("isHide", position);
    });
    if (this.pullUpload) {
      this.scroll.on("pullingUp", () => {
        this.$emit("pullingUp");
      });
    }
  },
};
</script>

<style scoped></style>
